package test

import "net/http"
import "fmt"
import "log"
import "github.com/go-martini/martini"
import "io/ioutil"
import "server/web/model/test"
import "server/lib/Imartini"

// import "server/lib/other/cmem"

// import "reflect"

func index(res http.ResponseWriter, req *http.Request, c martini.Context, log *Imartini.Mlog) string {
	// var sum, total int64
	// total = 0
	// sum = 0
	// for sum < 1000000 {
	// 	sum += 1
	// 	total += sum
	// }
	////////////////////
	log.Printf("%s", req.Header)
	i := test.Testdb2()
	////////////////
	// fmt.Fprintln(res, total)
	res.Write([]byte("hhhwww<br>"))
	// log.Println("...")
	return i[1]["name"]
}

func test2(res http.ResponseWriter, req *http.Request, log *Imartini.Mlog) { // res 和 req 是通过Martini注入的
	rows, _ := test.Testdb()
	fmt.Fprintln(res, rows[1]["name"])
	// log.Printf("%s", rows[1]["wxname"])

	fmt.Fprintln(res, "kkk")
}

func name(params martini.Params, res http.ResponseWriter, req *http.Request, log *log.Logger) string {
	log.Println(req.Form)
	response, _ := http.Get("http://www.baidu.com")
	defer response.Body.Close()
	body, _ := ioutil.ReadAll(response.Body)
	res.Write(body)
	return params["name"]
}
